<template>
	<view class="addVillage">
		<view class="addCon">
			<view class="cancelIcon" @click="cancel">
				<image :src="$IMG_URL+'index/cancel.png'" mode=""></image>
			</view>
			<view class="flex-row">
				<view class="addTitle">添加备注</view>
			</view>
			<view class="addcontent">
				<textarea   v-model="remarks" placeholder="请输入内容"></textarea>
			</view>
			<view class="flex-row addBtn">
				<view class="cancelBtn" @click="cancel">取消</view>
				<view class="sureBtn" @click="submit">确认</view>
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
		<u-cell-group title-bg-color="rgb(243, 244, 246)" v-show="false">
			<u-cell
				:titleStyle="{fontWeight: 500}"
				:title="item.title"
				v-for="(item, index) in list"
				:key="index"
				isLink
				:icon="item.iconUrl"
				@click="showToast(item)"
			>
			</u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				list: [
					{
						type: 'error',
						icon: false,
						title: '失败主题',
						message: "请输入小区名称",
						iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/error.png'
					}
				],
				remarks:'',
				consumerId:'',
				ordersType:'',//判断身份工长或巡检
			}
		},
		onLoad(option) {
			console.log(option)
			this.consumerId = option.userId;
			this.ordersType = option.ordersType;
		},
		methods: {
			gettype(){
				
			},
			cancel(){
				let  pageNum = 2
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - pageNum]; 
				uni.navigateBack({
					success: function() {
						console.log(beforePage)
						// beforePage.$vm.$refs.onSiteIndex.getdate();
					}
							
				})
			},
			submit(){
				if(this.remarks == ''){
					uni.showToast({
						icon:"error",
						title:'请输入备注'
					})
				}else{
					if(this.ordersType == '105'){
						// 巡检员设置业主备注
						this.$http('foreman.setInspectionConsumerRemark',{
							consumerId:this.consumerId,
							remark:this.remarks
						}).then(res=>{
							if(res.code==200){
								uni.navigateBack({
									delta:1
								})
							}else{
								this.$u.toast(res.msg);
							}
						})
					}else{
						// 工长设置业主备注
						this.$http('foreman.setConsumerRemark',{
							consumerId:this.consumerId,
							remark:this.remarks
						}).then(res=>{
							if(res.code==200){
								uni.navigateBack({
									delta:1
								})
							}else{
								this.$u.toast(res.msg);
							}
						})
					}
					
					
				}
			}
		}
	}
</script>

<style scoped>
	page{
		background-color: rgba(0, 0, 0, 0.3);
	}
	.addVillage{
		
	}
	.addCon{
		position: fixed;
		top:30%;
		left: 11%;
		width: 80%;
		height: 600rpx;
		background-color: #fff;
		border-radius: 28rpx;
	}
	.addTitle{
		width: 100%;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 36rpx;
		
	}
	.cancelIcon{
		width: 30rpx;
		height: 30rpx;
		position: absolute;
		top: 20rpx;
		right: 3%;
	}
	.cancelIcon image{
		width: 100%;
		height: 100%;
	}
	.addcontent{
		width: 90%;
		margin: 0 auto;
		height: 60%;
		background-color: #F6F7F9;
		border-radius: 28rpx;
		padding: 20rpx ;
	}
	.addcontent textarea{
		width: 100%;
		height: 100%;
		background-color: #F6F7F9 !important;
		border-radius: 28rpx;
		border: 0 none;
	}
	.addBtn{
		width: 80%;
		margin: 0 auto;
		margin-top: 20rpx;
		justify-content: space-between;
	}
	.cancelBtn{
		width: 44%;
		height: 60rpx;
		background-color: #F6F7F9;
		text-align: center;
		border-radius: 36rpx;
		font-size: 30rpx;
		line-height: 60rpx;
	}
	.sureBtn{
		width: 44%;
		height: 60rpx;
		text-align: center;
		border-radius: 36rpx;
		background-color: #1A76F2;
		color: #fff;
		font-size: 30rpx;
		line-height: 60rpx;
	}
	
</style>
